// Replication Code for "The Missing Dimension of the Political Resource Curse Debate"
// Ranjit Lall, Comparative Political Studies
// 12 July 2016

// Note: datasets are identified by the last name of each author, the date of publication, and the suffix "Original Data" or "Imputed Data"

// Ross 2001 ("Does Oil Hinder Democracy?", World Politics)
// Replication of Original Results
use "Ross 2001 Original Data.dta"

// Table 2 (in Lall article)
gen large = (wdr344>1000000)
// Model 1
xtgls  regime1 l5.regime1 l5.oil l5.metal l5.logGDPcp l5.islam l5.oecd l5.large i.year1, corr(psar1) force

// Model 2
xtgls  regime1 l5.regime1 l5.oil l5.metal l5.logGDPcp l5.islam l5.oecd l5.mideast l5.ssafrica i.year1, corr(psar1) force

// Model 3
gen arab = (id1 ==21| id1 ==149| id1 ==107| id1 ==162| id1 ==205| id1 ==7)
xtgls  regime1 l5.regime1 l5.oil l5.metal l5.logGDPcp l5.islam l5.oecd l5.arab l5.ssafrica i.year1, corr(psar1) force

// Reanalysis with Imputed Data
clear
use "Ross 2001 Imputed Data.dta"
mi import flong, m(imp) id(id1 year1) imp(wdr6-metal_5)
mi xtset id1 year1

gen large = (wdr344>1000000)
// Model 1
mi estimate, cmdok post: xtgls  regime1 l5.regime1 l5.oil l5.metal l5.cgdp l5.islam l5.oecd l5.large i.year1, corr(psar1) force

// Model 2
mi estimate, cmdok post: xtgls  regime1 l5.regime1 l5.oil l5.metal l5.cgdp l5.islam l5.oecd l5.mideast l5.ssafrica i.year1, corr(psar1) force

// Model 3
gen arab = (id1 ==21| id1 ==149| id1 ==107| id1 ==162| id1 ==205| id1 ==7)
mi estimate, cmdok post: xtgls  regime1 l5.regime1 l5.oil l5.metal l5.cgdp l5.islam l5.oecd l5.ssafrica l5.arab i.year1, corr(psar1) force)

// Ramsay 2011 ("Revisiting the Resource Curse: Natural Disasters, the Price of Oil, and Democracy", International Organization)
// Replication of Original Results
clear
use "Ramsay 2011 Original Data.dta"

// Table 3
// Model 1
tsset ccode year, yearly
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) i.year, robust bw(2)small rf endog(logoilrevpc) first savefirst savefprefix(first)

// Model 2
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Model 3
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Model 4
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth polity68 i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Reanalysis with Imputed Data
clear
use "Ramsay 2011 Imputed Data.dta"
mi import flong, m(imp) id(year ccode) imp(gdpgrowth-logreserv f_brit-logORDdef2k)

// Model 1
mi tsset ccode year, yearly
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) i.year, robust bw(2)small rf endog(logoilrevpc) first savefirst savefprefix(first)

// Model 2
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Model 3
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Model 4
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth polity68 i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Haber and Menaldo 2011 ("Do Natural Resources Fuel Authoritarianism? A Reappraisal of the Resource Curse", American Political Science Review; and Andersen and Ross 2014 ("The Big Oil Change: A Closer Look at the Haber-Menaldo Analysis", Comparative Political Studies)
// Replication of Original Results
insheet using "Haber and Menaldo 2011 Original Data.csv"

sort hmccode year
xtset hmccode year
gen log_gdp_per_cap_haber_men_2 = log(gdp_per_cap_haber_men_2)
replace total_oil_income_pc = total_oil_income_pc/1000
by hmccode: ipolate fiscal_reliance year, gen(Fiscal_Reliance_interpolate)
by hmccode: ipolate polity_s year, gen(polity_s_interpolate)
by hmccode: ipolate log_gdp_per_cap_haber_men_2 year, gen(LogPerCapGDP_interp)
by hmccode: ipolate civil_war year, gen(CivilWar_Interp)
by hmccode: ipolate total_oil_income_pc year, gen(Total_Oil_Income_PC_interp)
generate D_polity_s_interp = D.polity_s_interpolate
generate L_polity_s_interp = L.polity_s_interpolate
generate TOI_INC = Total_Oil_Income_PC_interp
generate L_tot_oil_inc_interp = L.TOI_INC
generate D_tot_oil_inc_interp = D.TOI_INC
generate L_LogPerCapGDP_interp = L.LogPerCapGDP_interp
generate L_CivilWar_interp = L.CivilWar_Interp
generate D_LogperCapGDP_int = D.LogPerCapGDP_interp
generate D_Region_Dem_Diffuse = D.region_dem_diffuse
generate L_REGION_DEM_DIFFUSE = L.region_dem_diffuse
generate D_World_Dem_Diffuse = D.world_dem_diffuse
generate L_WORLD_DEM_DIFFUSE = L.world_dem_diffuse
generate L_Fiscal_Reliance_interpolate = L.Fiscal_Reliance_interpolate
generate D_Fiscal_Reliance_interpolate = D.Fiscal_Reliance_interpolate

// Table 4
// Model 1
xi: xtscc D_polity_s_interp L_polity_s_interp L_tot_oil_inc_interp D_tot_oil_inc_interp L_LogPerCapGDP_interp L_CivilWar_interp L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE D_LogperCapGDP_int D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Model 2 (Andersen and Ross 2014)
generate post1980 = (year > 1980)
generate interaction1 = post1980*TOI_INC
generate linteraction1 = l.interaction1
generate dinteraction1 = d.interaction1

xi: xtscc D_polity_s_interp L_polity_s_interp L_tot_oil_inc_interp linteraction1 D_tot_oil_inc_interp dinteraction1 L_LogPerCapGDP_interp L_CivilWar_interp L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE D_LogperCapGDP_int D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Model 3
keep if Fiscal_Reliance_interpolate != . & cnamehabmen != "Saudi Arabia"
keep if polity_s_interpolate != .

xi: xtscc D_polity_s_interp L_polity_s_interp L_Fiscal_Reliance_interpolate D_Fiscal_Reliance_interpolate L_LogPerCapGDP_interp L_CivilWar_interp L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE D_LogperCapGDP_int D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Model 4 (Andersen and Ross 2014)
generate interaction2 = post1980*Fiscal_Reliance_interpolate
generate linteraction2 = l.interaction2
generate dinteraction2 = d.interaction2

xi: xtscc D_polity_s_interp L_polity_s_interp L_Fiscal_Reliance_interpolate linteraction2 D_Fiscal_Reliance_interpolate dinteraction2 L_LogPerCapGDP_interp L_CivilWar_interp L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE D_LogperCapGDP_int D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Reanalysis with Imputed Data
clear
use "Haber and Menaldo 2011 Imputed Data.dta"

mi import flong, m(imp) id(hmccode year) imp(polity_2-dinteraction2)
sort hmccode year
mi xtset hmccode year

// Model 1
xi: mi estimate, post cmdok: xtscc dpolity_s lpolity_s ltotal_oil_income_pc dtotal_oil_income_pc llog_gdp_per_cap_haber_men_2 lcivil_war L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE dlog_gdp_per_cap_haber_men_2 D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Model 2 (Andersen and Ross 2014)
xi: mi estimate, post cmdok: xtscc dpolity_s lpolity_s ltotal_oil_income_pc linteraction1 dtotal_oil_income_pc dinteraction1 llog_gdp_per_cap_haber_men_2 lcivil_war L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE dlog_gdp_per_cap_haber_men_2 D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Model 3
keep if fiscal_reliance!= . & hmccode != 670
keep if polity_s != .

xi: mi estimate, post cmdok: xtscc dpolity_s lpolity_s lfiscal_reliance dfiscal_reliance llog_gdp_per_cap_haber_men_2 lcivil_war L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE dlog_gdp_per_cap_haber_men_2 D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Model 4 (Andersen and Ross 2014)
xi: mi estimate, post cmdok: xtscc dpolity_s lpolity_s lfiscal_reliance linteraction2 dfiscal_reliance dinteraction2 llog_gdp_per_cap_haber_men_2 lcivil_war L_REGION_DEM_DIFFUSE L_WORLD_DEM_DIFFUSE dlog_gdp_per_cap_haber_men_2 D_Region_Dem_Diffuse D_World_Dem_Diffuse i.year i.hmccode, lag(1)

// Morrison 2009 ("Oil, Nontax Revenue, and the Redistributional Foundations of Regime Stability", International Organization)
// Replication of Original Results
clear
use "Morrison 2009 Original Data.dta"

// Table A4
// Model 1
logit politydv  l.grantspc l.otherpc l.soepc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Model 2
logit politydv  l.nontaxtotalpc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Model 3
gen politynontax = polity2*nontaxtotalpc
logit politydv l.nontaxtotalpc l.polity2 l.politynontax gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Split sample
// Table 5
// Model 1
logit politydv  l.soepc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity2 >=7 & l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Model 2
logit politydv  l.nontaxtotalpc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity2 >= 7 & l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Model 4
logit politydv  l.soepc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity2 <= 6 & l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Model 5
logit politydv  l.nontaxtotalpc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if l.polity2 <= 6 & l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Model 6 (pre-1980)
logit politydv  l.soepc gdpgrowth l.lnincome d.urbanpop elf  l.lnpopdens l.pastpolitydv polityage polityageknot1 polityageknot2 if year <= 1980 & l.polity2 <= 6 & l.polity~=-77 & polity~=-77 & polity2~=-77 & l.polity2~=-77, cluster(bankscode)

// Reanalysis with Imputed Data
clear
use "Morrison 2009 Imputed Data.dta"
summarize

mi import flong, m(imp) id(bankscode year) imp(age65-tradegdp polity-lpolity)
gen tenplus = 0
gen time0 = 0
gen leadgone = 0
mi stset, clear
mi xtset bankscode year
sort bankscode year

// Table A4
// Model 1
mi estimate, post: logit politydv  lgrantspc lotherpc lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Model 2
mi estimate, post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Model 3 (pre-1980)
mi estimate, post: logit politydv lnontaxtotalpc lpolity2 lpolitynontax gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if l.polity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Split sample
// Table 5
keep if l.polity2 >= 7
// Model 1
mi estimate, noisily post: logit politydv lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Model 2
mi estimate, noisily post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Model 3 (pre-1980)
keep if year <= 1980
mi estimate, noisily post: logit politydv lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Model 4
clear
use "Morrison 2009 Imputed Data.dta"
mi import flong, m(imp) id(bankscode year) imp(age65-tradegdp polity-lpolity)
gen tenplus = 0
gen time0 = 0
gen leadgone = 0
mi stset, clear
mi xtset bankscode year
sort bankscode year

keep if l.polity2 <= 6
// Model 4
mi estimate, post: logit politydv lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Model 5
mi estimate, post: logit politydv  lnontaxtotalpc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Model 6 (pre-1980)
keep if year <= 1980
mi estimate, noisily post: logit politydv lsoepc gdpgrowth llnincome durbanpop elf  llnpopdens lpastpolitydv polityage polityageknot1 polityageknot2 if lpolity~=-77 & polity~=-77 & polity2~=-77 & lpolity2~=-77, cluster(bankscode)

// Ross 2012 ("The Oil Curse: How Petroleum Wealth Shapes the Development of Nations" (book), Princeton University Press)
// Replication of Original Results
clear
use "Ross 2012 Original Data.dta"

// Table 6
// Transitions to democracy (panel 1)
// Model 2
keep if democracy_up_1 == 0
xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09, nolog

// Model 3
xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09 ///
if year<1980, nolog

// Model 4
xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09 ///
if year>1979, nolog

// Model 5
xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 latin_logoil_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09, nolog

// Model 6
xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 latin_logoil_1 ///
dem_prior_update gdpgrowth_alt_new_1 mus_pct_sup_1 ///
YEAR1960_64 YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09, nolog

// Transitions to authoritarianism (panel 2)
clear
use "Ross 2012 Original Data.dta"

// Model 2
relogit auth_transition log_demyrs_1 ///
logGDP_cap2000_sup_1  logoil_gas_valuePOP_1 ///
if democracy_up_1==1, cluster(id)

// Model 3
relogit auth_transition log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1  ///
if GDP_cap2000_sup<5000 & democracy_up_1==1 , cluster(id) 

// Model 4
relogit auth_transition log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1 ///
if GDP_cap2000_sup>5000 & democracy_up_1==1 , cluster(id)

// Model 5
relogit auth_transition log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1  ///
if year<1980 & democracy_up_1==1 , cluster(id) 

// Model 6
relogit auth_transition log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1  ///
if year>1979 & democracy_up_1==1 , cluster(id) 

// Reanalysis with Imputed Data
clear
use "Ross 2012 Imputed Data.dta"
mi import flong, m(imp) id(id year) imp(asia-YEAR2005_09)
encode(id), gen(id_number)
mi xtset id_number year
sort id_number year

gen democracy_up_1_round = int(democracy_up_1)

// Table 6
// Transitions to democracy (panel 1)
// Model 2
mi estimate, esampvaryok esample(newvar2) post: logit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09 ///
if democracy_up_1 == 0

// Model 3
mi estimate, esampvaryok esample(newvar3) post: xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09 ///
if year<1980 & democracy_up_1 == 0

// Model 4
mi estimate, esampvaryok esample(newvar4) post: xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09 ///
if year>1979 & democracy_up_1 == 0

// Model 5
mi estimate, esampvaryok esample(newvar5) post: xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 latin_logoil_1 YEAR1960_64 ///
YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09 ///
if democracy_up_1 == 0

// Model 6
mi estimate, esampvaryok esample(newvar6) post: xtlogit dem_transition logGDP_cap2000_sup_1 ///
log_authyrs_1 logoil_gas_valuePOP_1 latin_logoil_1 ///
dem_prior_update gdpgrowth_alt_new_1 mus_pct_sup_1 ///
YEAR1960_64 YEAR1965_69 YEAR1970_74 YEAR1975_79 ///
YEAR1980_84 YEAR1985_89 YEAR1990_94 ///
YEAR1995_99 YEAR2000_04 YEAR2005_09 ///
if democracy_up_1 == 0, nolog

// Transitions to authoritarianism (panel 2)
clear
use "Ross 2012 Imputed Data.dta"
mi import flong, m(imp) id(id year) imp(asia-female_seats)
encode(id), gen(id_number)
mi xtset id_number year
sort id_number year
gen auth_transition_round = int(auth_transition)

// Model 2
mi estimate, cmdok esampvaryok esample(newvar8) post: relogit auth_transition_round log_demyrs_1 ///
logGDP_cap2000_sup_1  logoil_gas_valuePOP_1 ///
if democracy_up_1 ==1, cluster(id) 

// Model 3
mi estimate, cmdok esampvaryok esample(newvar9) post: relogit auth_transition_round log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1  ///
if GDP_cap2000_sup<5000 & democracy_up_1 ==1 , cluster(id) 

// Model 4
mi estimate, cmdok esampvaryok esample(newvar10) post: relogit auth_transition_round log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1 ///
if GDP_cap2000_sup>5000 & democracy_up_1 ==1 , cluster(id) 

// Model 5
mi estimate, cmdok esampvaryok esample(newvar11) post: relogit auth_transition_round log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1  ///
if year<1980 & democracy_up_1 ==1 , cluster(id) 

// Model 6
mi estimate, cmdok esampvaryok esample(newvar12) post: relogit auth_transition_round log_demyrs_1 ///
logGDP_cap2000_sup_1 logoil_gas_valuePOP_1  ///
if year>1979 & democracy_up_1 ==1 , cluster(id)

// Wright, Frantz, and Geddes 2015 ("Oil and Autocratic Regime Survival", British Journal of Political Science)
// Replication of Original Results
clear
use "Wright, Frantz, and Geddes 2015 Original Data.dta"

// Table 7
// All years
// Panel A: All regime failures
// Model 1
xi: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
xi: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
xi: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_fail, cluster(cow)

// Panel B: Democratic Transitions
// Model 1
xi: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
xi: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
xi: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dem, cluster(cow)

// Panel C: Autocratic transitions
// Model 1
xi: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
xi: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
xi: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dict, cluster(cow)

// Pre-1981
keep if year <= 1980

// Panel A: All regime failures
// Model 1
xi: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
xi: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
xi: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_fail, cluster(cow)

// Panel B: Democratic Transitions
// Model 1
xi: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
xi: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
xi: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dem, cluster(cow)

// Panel C: Autocratic transitions
// Model 1
xi: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
xi: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
xi: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dict, cluster(cow)

// Reanalysis with Imputed Data
clear
use "Wright, Frantz, and Geddes 2015 Imputed Data.dta"
mi import flong, m(imp) id(year cowcode) imp(world_dem_diffuse-total_resources_income_pc xhm_oil price_oil)
gen _t0 = 0
gen _t = 0
gen _d = 0
gen _st = 0
gen wdi = 0
gen leadnew = 0

// Panel A: All regime failures
// Model 1
mi estimate, post: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cowcode)

// Model 4
mi estimate, post: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
mi estimate, post: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_fail, cluster(cow)

// Panel B: Democratic transitions
// Model 1
mi estimate, post: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
mi estimate, post: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
mi estimate, post: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dem, cluster(cow)

// Panel C: Autocratic transitions
// Model 1
mi estimate, post: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
mi estimate, post: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
mi estimate, post:logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dict, cluster(cow)

// Post-1981
keep if year <= 1980

// Panel A: All regime failures
// Model 1
mi estimate, post: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cowcode)

// Model 4
mi estimate, post: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
mi estimate, post: logit ged_fail  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_fail, cluster(cow)

// Panel B: Democratic transitions
// Model 1
mi estimate, post: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
mi estimate, post: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
mi estimate, post: logit ged_dem  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dem, cluster(cow)

// Panel C: Autocratic transitions
// Model 1
mi estimate, post: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  hm_oil , cluster(cow)

// Model 4
mi estimate, post: logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil , cluster(cow)

// Model 6
mi estimate, post:logit ged_dict  ged_time* time time2 time3 mean_gdp dev_gdp civilwar nbr_dem  mean_hmoil dev_hmoil mean_dict, cluster(cow)
